home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / bin / X11 / xroot < prev    next >
Text File  |  1995-07-13  |  5KB  |  224 lines

  1. :
  2. # xroot - selects from a variety of image format files
  3. #         for use as a mirror tiled root window
  4. #
  5. # Usage: xroot [-e | -j | -l | -s | -r | -u | -n # | -p # | -N # | -P # | 
  6. #               -m | directory or file name | -b]
  7. #
  8. # Takes as an argument the directory in which to find files
  9. # If the argument is not a directory, then it assumes it's an image file
  10. # If the argument is the string "-r", it displays a random GIF from /z/gif.
  11. # If the argument is "-e", it displays a random endo PPM
  12. # If the argument is "-l", it displays a random lyap PPM
  13. # If the argument is "-f", it displays a random Fractal PPM
  14. # If the argument is "-j", it displays a random Julia/Mandelbrot set
  15. # If the argument is "-s", it displays a random Nasa Space GIF
  16. # Additionally, arguments of "-n num" indicate select amongst the 1st num pics
  17. # "-p num" indicates pick the num'th picture
  18. # "-N num" indicates select amongst the 1st num directories
  19. # "-P num" indicates pick the num'th directory
  20. # "-m" indicates use full root window rather than tiling
  21. # "-b" indicates browse and select from available pics
  22. #
  23. # by Ron Record (rr@sco.com) 10 Sep 1992
  24. #
  25.  
  26. PROG=$0
  27. GROOT=/usr/skunk/pics/gif
  28. FILE=
  29. BROW=
  30. TILE="-rmode 2"
  31. DIR=$GROOT/ocean
  32. EDIR=$GROOT/endo
  33. HDIR=$GROOT/hop
  34. MDIR=$GROOT/spore
  35. JDIR=$GROOT/julia
  36. LDIR=$GROOT/lyap
  37. SDIR=$GROOT/xtopo
  38. CMD="xv -perfect -noresetroot -owncmap -root -quit"
  39. DEF_PIC=$LDIR/monsters.gif
  40. NUM=
  41. FNUM=
  42. DNUM=
  43. PNUM=
  44.  
  45. Usage() {
  46.     echo "Usage: $PROG [-p num | -n num | -P num | -N num | -m |"
  47.     echo "    -e | -j | -l | -r | -s | -f | -u | directory or file name | -b]"
  48.     echo "    Where :    "
  49.     echo "        -b indicates browse and select from available pics"
  50.     echo "        -e indicates display an Endomorphism diagram"
  51.     echo "        -f indicates display a Fractal picture"
  52.     echo "        -j indicates display a Julia/Mandelbrot set"
  53.     echo "        -l indicates display a Lyapunov diagram"
  54.     echo "        -s indicates display a Nasa image"
  55.     echo "        -r indicates randomly display saved picture"
  56.     echo "        -m indicates use full screen rather than tiling"
  57.     echo "        -u displays this message"
  58.     echo "\n$PROG is a shell script front-end for xv."
  59.     echo "It was written by Ronald Joe Record and can be used to decorate."
  60.     echo "the root window with a GIF, TIFF, PPM or any other image xv reads."
  61.     echo "When invoked with no arguments, it displays the monster lyap GIF."
  62.     echo "To cycle through a set of images, use croot.\n"
  63.     exit 1
  64. }
  65.  
  66. ReCycle() {
  67.     for j in $DIR/*
  68.     do
  69.         [ $i -gt $FNUM ] && {
  70.             echo "\nPlease wait while i tile your root window ...\c"
  71.             $CMD $TILE $j
  72.             echo "\nDo you prefer this as your root window ? (y/n)\c"
  73.             read ans
  74.             [ "$ans" = "y" ] || [ "$ans" = "Y" ] && break
  75.         }
  76.         i=`expr $i + 1`
  77.         [ $i -gt $NUM ] && break
  78.     done
  79. }
  80.  
  81. Browse() {
  82.     [ -d "$DIR" ] || {
  83.         echo "Warning: $DIR does not exist or is not a directory"
  84.         exit 1
  85.     }
  86.     [ "$NUM" = "" ] && NUM=`ls -l $DIR | wc -l`
  87.     NUM=`expr $NUM - 1`
  88.     [ $NUM -gt 255 ] && NUM=255
  89.     [ "$FNUM" = "" ] && FNUM=`random $NUM`
  90.     i=0
  91.     ReCycle
  92.     [ "$ans" = "y" ] || [ "$ans" = "Y" ] || {
  93.         [ $i -lt $NUM ] && ReCycle    
  94.         [ "$ans" = "y" ] || [ "$ans" = "Y" ] || {
  95.             echo "Well, i'm all out of that variety of root images."
  96.             echo "Please select another category and try again."
  97.             echo "I will leave the root window as it is now."
  98.         }
  99.     }
  100. }
  101.  
  102. Select() {
  103.     [ -d "$DIR" ] || {
  104.         echo "Warning: $DIR does not exist or is not a directory"
  105.         exit 1
  106.     }
  107.     [ "$NUM" = "" ] && NUM=`ls -l $DIR | wc -l`
  108.     NUM=`expr $NUM - 1`
  109.     [ $NUM -gt 255 ] && NUM=255
  110.     [ "$FNUM" = "" ] && FNUM=`random $NUM`
  111.     i=0
  112.  
  113.     for j in $DIR/*
  114.     do
  115.         [ "$i" = "" ] && echo "i is empty"
  116.         [ "$FNUM" = "" ] && echo "FNUM is empty with NUM = $NUM and DIR=$DIR"
  117.         [ $i = $FNUM ] && {
  118.             $CMD $TILE $j
  119.             break
  120.         }
  121.         i=`expr $i + 1`
  122.     done
  123. }
  124.  
  125. DirSelect() {
  126.     [ "$DNUM" = "" ] && {
  127.         DNUM=`ls -l $ARGDIR | wc -l`
  128.         DNUM=`expr $DNUM - 1`
  129.     }
  130.     [ "$PNUM" = "" ] && PNUM=`random $DNUM`
  131.     [ $PNUM -gt 255 ] && PNUM=255
  132.     i=0
  133.  
  134.     for j in $ARGDIR/*
  135.     do
  136.         [ "$j" = "$ARGDIR/small" ] && continue
  137.         [ $i = $PNUM ] && {
  138.             DIR=$j
  139.             break
  140.         }
  141.         i=`expr $i + 1`
  142.     done
  143. }
  144.  
  145. [ $# = 0 ] && {
  146.     $CMD $TILE $DEF_PIC
  147.     exit 0
  148. }
  149.  
  150. while case "$1" in
  151.     usage)  Usage
  152.         ;;
  153.     -b)    BROW=True
  154.         ;;
  155.     -m)    TILE="-max"
  156.         ;;
  157.     -n)    NUM=$2
  158.         shift
  159.         ;;
  160.     -p)    FNUM=$2
  161.         shift
  162.         ;;
  163.     -e)     DIR=$EDIR
  164.         ;;
  165.     -h)     DIR=$HDIR
  166.         ;;
  167.     -j)     DIR=$JDIR
  168.         ;;
  169.     -k)     DIR=$MDIR
  170.         ;;
  171.     -l)     DIR=$LDIR
  172.         ;;
  173.     -f) ;;
  174.     -r)     ARGDIR=$GROOT
  175.             DirSelect
  176.         ;;
  177.     -s)     DIR=$SDIR
  178.         ;;
  179.     "")     break
  180.         ;;
  181.      *) if [ -d $1 ]
  182.         then
  183.             DIR=$1
  184.         else
  185.             if [ -f $1 ]
  186.             then
  187.                 FILE=$1
  188.             else
  189.                 if [ -f $DIR/$1 ] 
  190.                 then
  191.                     FILE=$DIR/$1
  192.                 else
  193.                     if [ -d $GROOT/$1 ] 
  194.                     then
  195.                         DIR=$GROOT/$1
  196.                     else
  197.                         [ -f $EDIR/$1 ] && FILE=$EDIR/$1
  198.                         [ -f $JDIR/$1 ] && FILE=$JDIR/$1
  199.                         [ -f $LDIR/$1 ] && FILE=$LDIR/$1
  200.                         [ "$FILE" = "" ] && Usage
  201.                     fi
  202.                 fi
  203.             fi
  204.         fi
  205.         ;;
  206.         esac
  207. do
  208.     shift
  209. done
  210.  
  211. if [ "$BROW" = "True" ]
  212. then
  213.     Browse
  214. else
  215.     if [ "$FILE" = "" ]
  216.     then
  217.         Select
  218.     else
  219.         $CMD $TILE $FILE
  220.     fi
  221. fi
  222.  
  223. exit 0
  224.